package com.itheima.grow.controller;

import com.itheima.grow.model.other.Result;
import com.itheima.grow.service.OssService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

@Slf4j
@RestController
@RequestMapping("/easy")
public class FileUploadController {

    @Resource
    private OssService ossService;


    @PostMapping("/upload")
    public Result uploadOSSFile(@RequestBody MultipartFile file){
        //获取上传文件 MultipartFile
        //返回上传到oss的路径
        return Result.success(ossService.uploadFile(file));
    }
}
